package netapp.udp_multicast;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

public class Client {
    public static void main(String[] args) throws IOException {
//        - 发送端
//        1. 创建发送端的Socket对象(DatagramSocket)
        DatagramSocket ds = new DatagramSocket();
//        2. 创建数据，并把数据打包(DatagramPacket)
        byte[] bytes = "两只🐅🐅爱💃💃".getBytes();
        DatagramPacket packet = new DatagramPacket(bytes, bytes.length, InetAddress.getByName("239.250.250.250"),8888);
//        3. 调用DatagramSocket对象的方法发送数据(在单播中,这里是发给指定IP的电脑但是在组播当中,这里是发给组播地址)
        ds.send(packet);
//        4. 释放资源
        ds.close();
    }
}
